package com.gc.controller.studentServlet;

import com.gc.repository.StuCheckRepository;
import com.gc.repository.impl.StuCheckRepositoryImpl;
import com.gc.service.StudentService;
import com.gc.service.impl.StudentServiceImpl;
import com.gc.util.result.R;
import com.gc.vo.ShowClassByStudent;
import com.google.gson.Gson;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "UpdateStuStage", value = "/UpdateStuStage")
public class UpdateStuStage extends HttpServlet {
    StuCheckRepository stuCheckRepository = new StuCheckRepositoryImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new Gson();
        Long id = Long.valueOf(request.getParameter("id"));
        Integer stage = Integer.valueOf(request.getParameter("stage"));

        boolean res = stuCheckRepository.UpdateStageById(id, stage);
        if(res) {
            if(res) {
                response.getWriter().write(gson.toJson(R.ok()));
            } else {
                response.getWriter().write(gson.toJson(R.error()));
            }
        }
    }
}
